home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: ave@ix.netcom.com(Alexander Berdichevsky )
- Newsgroups: comp.lang.c++
- Subject: Re: Argc & Argv
- Date: 28 Feb 1996 13:36:52 GMT
- Organization: Netcom
- Message-ID: <4h1lpk$dg7@cloner4.netcom.com>
- References: <4gta9f$df5@netlab.cs.rpi.edu>
- NNTP-Posting-Host: ix-prn1-07.ix.netcom.com
- X-NETCOM-Date: Wed Feb 28 5:36:52 AM PST 1996
-
-
- >I have some global objects defined outside the main routine and I
- would
- >like to pass the argc and argv values to their constructors. For
- example,
- >
- >
- >SomeClass obj( argc, argv);
- >
- >int main( int argc, char **argv) {
- >
- > blah, blah, blah
- >
- >}
- >
- >Unfortunately, the compiler tells me that argc and argv are not
- defined
- >or else not available for obj.
- >
- >Currently, I get around this problem by creating the global obj and
- then
- >inside of main, I initialize obj via a method that takes argc and
- argv.
- >
- >I would prefer to pass the arg vars to the constructor. Does anyone
- know
- >how I can pass the arg vars without being inside of main?
-
- 1. All dynamical initialization for global variables are before main
- function;
- 2. argc and argv dynamically passed to the main function from a command
- line;
-
- Therefore you can not use them before main function started.
-
- Best regards
-
- Alex
-